﻿@{
    ViewBag.Title = "Upload";
}

<h2>Upload</h2>
<input id="fileupload" type="file" name="files[]" data-url="/lib/imgs/ImgUploadJson" accept="image/jpg|image/bmp" multiple>
<div id="img"></div>

@section scripts{
    @Scripts.Render("~/bundles/jquery-fileupload")

<script type="text/javascript">
    $(function () {
        $('#fileupload').fileupload({
            dataType: 'json',
            add: function (e, data) {
                data.context = $('<p/>').text('Uploading...').appendTo(document.body);
                data.submit();
            },
            done: function (e, data) {
                data.context.text('Upload finished.');
                $.each(data.result, function (index, file) {
                    $('<p/>').text(file.name).appendTo(document.body);
                    $("#img").append('<img src="'+file.url+'"/>');
                });
            }
        });
    });
</script>
}